package com.xs.project.controller;

import com.xs.project.common.Result;
import com.xs.project.pojo.vo.*;
import com.xs.project.pojo.vo.resp.*;
import com.xs.project.service.LoginService;
import com.xs.project.service.SysMsgService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/loginManager")
@Api(tags = "登录模块")
public class LoginController {
    @Resource
    private LoginService loginService;
    @Resource
    private SysMsgService sysMsgService;

    @ApiOperation(value = "登录", notes = "登录")
    @PostMapping(value = "/login")
    public Result<UserInfoResp> login(@RequestBody LoginReq req) {
        return loginService.login(req);
    }

    @ApiOperation(value = "注册", notes = "注册")
    @PostMapping(value = "/register")
    public Result<Boolean> register(@RequestBody LoginReq req) {
        return loginService.register(req);
    }

    @ApiOperation(value = "获取邮件验证码", notes = "重置")
    @PostMapping(value = "/emailCode")
    public Result<String> emailCodee(@RequestBody LoginReq req) {
        return loginService.emailCode(req.getEmailNum());
    }

    @ApiOperation(value = "重置", notes = "重置")
    @PostMapping(value = "/resPassword")
    public Result<Boolean> resPassword(@RequestBody LoginReq req) {
        return loginService.resPassword(req);
    }

    @ApiOperation(value = "课程列表-首页", notes = "课程列表-首页")
    @PostMapping(value = "/getCourseList")
    public Result<List<CourseVo>> getCourseList(@RequestBody CourseReq req) {
        return loginService.getCourseList(req);
    }

    @ApiOperation(value = "列表-公告", notes = "公告列表")
    @PostMapping(value = "/selectSysMsg")
    public Result<List<SysMsgResp>> selectSysMsg(@RequestBody SysLogReq req) {
        return sysMsgService.selectSysMsg(req);
    }

    @ApiOperation(value = "热点-首页", notes = "课程列表-首页")
    @PostMapping(value = "/getHotCourseList")
    public Result<List<CourseVo>> getHotCourseList(@RequestBody CourseReq req) {
        return loginService.getHotCourseList(req);
    }

    @ApiOperation(value = "课程详情页", notes = "课程列表-首页")
    @GetMapping(value = "/getCourseDetail")
    public Result<CourseDetailVo> getCourseDetail(String courseId,String userId) {
        return loginService.getCourseDetail(courseId,userId);
    }

    @ApiOperation(value = "考试详情页", notes = "考试列表-首页")
    @GetMapping(value = "/getExamDetail")
    public Result<ExamVo> getExamDetail(String examId) {
        return loginService.getExamDetail(examId);
    }

    @ApiOperation(value = "试卷提交", notes = "试卷提交")
    @PostMapping(value = "/subExamDetail")
    public Result<Boolean> subExamDetail(@RequestBody SubExamTitleReq req) {
        return loginService.subExamDetail(req);
    }

    @ApiOperation(value = "根据用户id获取考试id", notes = "试卷提交")
    @GetMapping(value = "/getExamIdByUserId")
    public Result<Integer> getExamIdByUserId(String userId) {
        return loginService.getExamIdByUserId(userId);
    }
    @ApiOperation(value = "作业提交", notes = "作业提交")
    @PostMapping(value = "/saveHomeWork")
    public Result<Boolean> saveHomeWork(@RequestBody HomeWorkVo courseResourceVo){
        return loginService.saveHomeWork(courseResourceVo);
    }

    @GetMapping(value = "/getExamRes")
    public Result<String> getExamRes(String userId){
        return loginService.getExamRes(userId);
    }

}
